package com.example.demo.controller;


import com.example.demo.ao.External;
import com.example.demo.ao.PaymentByCodeAo;
import com.example.demo.service.PaymentByCodeService;
import com.example.demo.vo.PaymentByCodeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/member/payment/code")
public class PaymentByCodeController {

    @Autowired
    private PaymentByCodeService paymentByCodeService;

    @PostMapping("/info")
    public List<PaymentByCodeVo> getPaymentByCodeInfo(@RequestBody PaymentByCodeAo paymentByCodeAo){
        List<PaymentByCodeVo> paymentByCodeInfo = paymentByCodeService.getPaymentByCodeInfo(paymentByCodeAo);
        return paymentByCodeInfo;
//        return R.ok(PageUtil.listToPage(paymentByCodeInfo,paymentByCodeAo));
    }


    @PostMapping("/resrc/suplCode")
    public int getResrcSuplCode(@RequestBody List<PaymentByCodeAo> paymentByCodeAos){
        int num = 0;
        num = paymentByCodeService.getResrcSuplCode(paymentByCodeAos);
        if (num != 0){
            return 1;
        }else {
            return 0;
        }
    }


//    加解密
    @PostMapping("/meter/info")
    public String getMeterInfo(@RequestBody External meterInfoAos){
        return paymentByCodeService.getMeterInfo(meterInfoAos);
    }


//    加解密
    @PostMapping("/meter/decrypt")

    public Object decrypt(@RequestBody String meterInfoAos){
        return paymentByCodeService.decrypt(meterInfoAos);
    }
}
